import 'package:json_annotation/json_annotation.dart';

part 'order_model.g.dart';

@JsonSerializable()
class OrderModel {
  /// 用户姓名
  final String username;

  ///  配送地址
  final String address;

  /// 近多少天
  final int days;

  /// 下单次数
  final int count;

  /// 时间 HH:MM
  final String time;

  /// 剩余时间
  final int overMinutes;

  /// 商品数量
  final List<CommodityModel> shops;

  /// 技术费用
  final double tecCost;

  /// 收入
  final double income;

  /// 订单号
  final String orderNo;

  /// 下单时间
  final String createTime;

  OrderModel(
      {required this.username,
      required this.time,
      required this.address,
      required this.days,
      required this.count,
      required this.overMinutes,
      this.shops = const [],
      required this.tecCost,
      required this.income,
      required this.orderNo,
      required this.createTime});

  factory OrderModel.fromJson(Map<String, dynamic> json) => _$OrderModelFromJson(json);

  Map<String, dynamic> toJson() => _$OrderModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}

@JsonSerializable()
class CommodityModel {
  /// 商品名称
  String name;

  /// 商品图片
  String iconUrl;

  CommodityModel({required this.name, required this.iconUrl});

  factory CommodityModel.fromJson(Map<String, dynamic> json) => _$CommodityModelFromJson(json);

  Map<String, dynamic> toJson() => _$CommodityModelToJson(this);

  @override
  String toString() {
    return toJson().toString();
  }
}
